package controller.material;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry.Entry;

import service.CoffeeService;
import to.JobTO;
import util.CoffeeUtil;

public class RostingBeansSlio extends Thread {
	private CoffeeService service;

	public RostingBeansSlio(CoffeeService service) {
		this.service = service;
	}

	@Override
	public void run() {
		while (true) {
			try {
				int totalWeight = service.selectSiloBeansTotalWeight("배전두silo");
				int bigBeansWeight = service.selectBigBeansTotalWeight();
				if (totalWeight < CoffeeUtil.ROSTING_TOTAL_WEIGHT||bigBeansWeight < CoffeeUtil.BIG_BEANS_TOTAL_WEIGHT){
					if(service.selectMachineWaitingJob("로스터") == 0){
						// 로스팅 대기작업 +1
						System.out.println("로스팅작업 추가");
						service.updateMachineWaitingJob("로스터", 1);
					}
				}
				
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
}
